class Admin::PropertiesController < Admin::AdminController
  #filter_access_to :all
  
  autocomplete :property, :presentation, :full => false
  autocomplete :property_attribute, :presentation, :full => false
  autocomplete :property_value, :value, :full => false, :display_value => :display_property_value, :extra_data => [:metric_id]

  def get_autocomplete_items(parameters)
    items = super(parameters)

    if parameters[:model].to_s == "PropertyAttribute"
      items = items.where(:property_id => params[:property_id]).group("presentation")
    elsif parameters[:model].to_s == "Property"
      items = items.group("presentation")
    elsif parameters[:model].to_s == "PropertyValue"
      items = items.group("product_property_values.value, product_property_values.metric_id")
    end
  end
end